package info.motteke.qjdbc.column.variable;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public final class IntVariable extends Variable {

    private int value;

    private boolean set = false;

    public IntVariable(){

    }

    public IntVariable(int value) {
        is(value);
    }

    public void is(int value){
        this.value = value;
        set = true;
    }

    @Override
    void putValue(PreparedStatement pstmt, int index) throws SQLException {
        if(!set){
            throw new IllegalStateException("値が設定されていません。");
        }

        pstmt.setInt(index, value);
    }
}
